/*
 * @Description: 设置cookie
 * @version: V1.0.0
 * @Author: Shuangshuang Song
 * @Date: 2021-01-27 09:26:12
 * @LastEditTime: 2021-01-27 09:44:31
 * @LastEditors: Shuangshuang Song
 */
import Cookies from 'js-cookie';

/**
 * @name isElec
 * @description: 是否桌面端
 * @param {*}
 * @returns {*}
 */
export function isElec() {
  const elec = window.require && window.require('electron');
  return !!elec;
}
/**
 * @name getCookie
 * @description: 获取cookie
 * @param {*} key
 * @returns {*}
 */
export function getCookie(key) {
  if (isElec()) {
    return window.localStorage.getItem(key);
  }
  return Cookies.get(key);
}
/**
 * @name setCookie
 * @description: 设置cookie
 * @param {*} key
 * @param {*} value
 * @param {*} options
 * @returns {*}
 */
export function setCookie(key, value, options) {
  if (isElec()) {
    return window.localStorage.setItem(key, value);
  }
  Cookies.set(key, value, options);
}
